package jdbcForMe;

import jdbcForMe.mySetting.MyFormSetting;
import jdbcForMe.mySetting.MyItemSetting;
import jdbcForMe.setting.ItemSetting;

import java.lang.reflect.InvocationTargetException;
import java.sql.*;

public class Demo01 {
    public static void main(String[] args) {
//        try {
//
//            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/crawl", "root", "12345678");
//            Statement st = conn.createStatement();
//            String strFormatted = "%d %s";
//            String sql = "select id, name from hotelData";
//            ResultSet rs = st.executeQuery(sql);
//            while(rs.next()){
//                int id = rs.getInt("id");
//                String name = rs.getString("name");
//                String  str = String.format(strFormatted, id, name);
//                System.out.println(str);
//            }
//        } catch (SQLException throwables) {
//            throwables.printStackTrace();
//        }

        MyItemSetting<Integer> mis01 = new MyItemSetting<>(1, "朵尔曼国际酒店(广州南站店)");
        MyItemSetting<Integer> mis02 = new MyItemSetting<>(2, "壹加壹精品酒店(广州新白云国际机场店)");
        MyItemSetting<Integer> mis03 = new MyItemSetting<>(3, "城市便捷酒店(广州汉溪长隆市桥地铁站店)");
        MyItemSetting<Integer> mis04 = new MyItemSetting<>(4, "麗枫酒店(广州白云机场曙光路店)");
        MyItemSetting<Integer> mis05 = new MyItemSetting<>(5, "广东空港大酒店");
        MyItemSetting<Integer> mis06 = new MyItemSetting<>(6, "广东空港大酒店");

        MyFormSetting mfs = new MyFormSetting(mis01);
        mfs.mix(mis02);
        mfs.mix(mis03);
        mfs.mix(mis04);
        mfs.mix(mis05);

//        ItemSetting[] iss = mfs.select();

//        for(ItemSetting i : iss){
//            System.out.println(i);
//        }

//        System.out.println(mfs);
//        mfs.dispose();
//        System.out.println("-----------");
//        System.out.println(mfs);
        Long t1 = System.currentTimeMillis();
        while (mfs.hasNext()) {
            System.out.println(mfs.next());
        }
        Long t2 = System.currentTimeMillis();
        System.out.println(t2 - t1);

    }
}
